package com.site.dao.impl.dining;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import com.site.dao.dining.RestaurantDao;
import com.site.dto.dining.RestaurantBizBean;
import com.site.model.dining.RestaurantInfo;
import com.site.util.base.dao.BaseDaoImpl;
import com.site.util.base.dao.HQLHelper;
import com.site.util.extremetable.QueryPage;

/**
 * 餐厅Dao
 * @author jack
 *
 */
@Repository
public class RestaurantDaoImpl extends BaseDaoImpl implements RestaurantDao {

	@Override
	public List<RestaurantInfo> getRestaurants(QueryPage queryPage, RestaurantBizBean restaurantBizBean){
		HQLHelper hqlHelper = new HQLHelper("RestaurantInfo"); 
		if(null != restaurantBizBean){
			 if(!StringUtils.isEmpty(restaurantBizBean.getName())){
				 hqlHelper.addLike("name", restaurantBizBean.getName());
			 }
			 if(!StringUtils.isEmpty(restaurantBizBean.getRestaurantType())){
				 hqlHelper.addEqual("restaurantType", restaurantBizBean.getRestaurantType());
			 }
		}
		if(queryPage == null){
			return super.findByHQL(hqlHelper.toString(), null);
		} else {
			return super.findByHQL(queryPage, hqlHelper.getHQL(), null, false);
		}
	}
}
